<?php
$sn = "";
$mac = "";
if (isset($_POST['sn']) && isset($_POST['mac']))
{
    $sn = htmlspecialchars(addslashes($_POST['sn']));
    $mac = htmlspecialchars(addslashes($_POST['mac']));
}
?>
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>赚钱宝初始密码计算</title>
    </head>
    <body>
    <form action="" method="post">
        SN: <input type="text" name="sn"><br>
        MAC: <input type="text" name="mac"><br>
        <input type="submit">
    </form>
    <p style="color:red">
        <?php

        if ($mac && $sn){

            $enckey = 'i8e%Fvj24nz024@d!c';
            $str = $sn . $mac . $enckey;


            $tmp = base64_encode(md5($str,true)); //0x19 = 25

            for ($i=0; $i < strlen($tmp); $i++){
                if ( ord($tmp[$i])  == 43){
                    $tmp[$i] = chr(45);
                }
                if ( ord($tmp[$i])  == 47){
                    $tmp[$i] = chr(95);
                }
            }

            echo substr($tmp, 0, 8). "\n";

        }else{
            echo "请输入SN";
        }

        ?>
    </p>

    <a href="https://item.taobao.com/item.htm?_u=ketdgqf44b&id=530836282643">购买链接
        <br>
        https://item.taobao.com/item.htm?_u=ketdgqf44b&id=530836282643
    </a>
    <script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1257408959'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s4.cnzz.com/z_stat.php%3Fid%3D1257408959%26show%3Dpic' type='text/javascript'%3E%3C/script%3E"));</script>
    </body>
    </html>